<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
  <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="xx.do" method="post">
  <p>
  <span>用户名：</span><input type="text" id="username">
  </p>

<!--  单选框，多选框的值，都是已经定义好的value-->
  <p>
    <span>性别：</span>
    <input type="radio" name="sex" value="man" id="boy"> 男
    <input type="radio" name="sex" value="women" id="girl"> 女
  </p>
  <input type="submit">
</form>

<script>
  var in_username = document.getElementById("username");

  var boy_radio = document.getElementById("boy");
  var girl_radio = document.getElementById("girl");
  // 得到输入框的值
  in_username.value;

  // 对于单选框，多选框等固定的值，boy_radio.value只能取到当前的值
  boy_radio.checked; // 查看返回的结果是否为true，如果为true，则被选中
  boy_radio.checked = true; //赋值按钮
</script>
</body>
</html>